﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using LowLevelGraphics.Filter;

namespace LowLevelGraphics.Extractors
{
    /// <summary>
    /// 
    /// </summary>
    public class DefaultCombiner : IImagePyramidRenderOperations
    {
        protected List<IteratedFilter> m_aIteratedFilter = new List<IteratedFilter>();

        /// <summary>
        /// 
        /// </summary>
        public DefaultCombiner()
        {
        }

        /// <summary>
        /// Gets or sets iterated filter list
        /// </summary>
        public List<IteratedFilter> IteratedFilter
        {
            get { return m_aIteratedFilter; }
            set { m_aIteratedFilter = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_bitmap1"></param>
        /// <param name="_bitmap2"></param>
        public UnsafeBitmap Execute(UnsafeBitmap _bitmap1, UnsafeBitmap _bitmap2)
        {
            foreach (IteratedFilter filter in m_aIteratedFilter)
            {
                for (int i = 0; i < filter.Iterations; i++)
                {
                    ITwoSourceFilter iTwoSourceFilter = (filter as ITwoSourceFilter);
                    if (iTwoSourceFilter != null)
                    {
                        iTwoSourceFilter.Process(_bitmap1, _bitmap2);
                    }
                }
            }
            return _bitmap2;
        }
    }
}
